#include "ros/ros.h"
#include "sensor_msgs/JointState.h"
sensor_msgs::JointState msg;
void doPose(const sensor_msgs::JointState::ConstPtr& p){
    msg.header = p->header;
    msg.name =p->name;
    msg.effort =p->effort;
    msg.position = p->position;
    msg.velocity =p->velocity;

}

int main(int argc, char *argv[])
{
    setlocale(LC_ALL,"");
    // 2.初始化 ROS 节点
    ros::init(argc,argv,"sub_pose");
    // 3.创建 ROS 句柄
    
    ros::NodeHandle nh;
    ros::Subscriber sub = nh.subscribe<sensor_msgs::JointState>("/j2n6s300/joint_states",1000,doPose);
    ros::Publisher pub = nh.advertise<sensor_msgs::JointState>("/joint_states",1000);
    // 4.创建订阅者对象

    // 5.回调函数处理订阅的数据
    // 6.spin
    while(ros::ok())
    {
    ros::spinOnce();
    pub.publish(msg);
    }
    return 0;
}